#!/bin/sh
TFILE="/media/testdrive/result.txt"

#Esperamos hasta que se haya completado el arranque
while ! test -f /var/run/runlevel; do
	sleep 1
done

echo "----- STARTING TEST -----"
echo " EXECUTING TEST IN `pwd`" > $TFILE

echo "Repository index file: " >> $FILE
wget http://localhost:9000/index.txt -O - >> $TFILE 2>&1

OD="/usr/local/opendomo"
su -c "$OD/updatePackageList.sh" admin >> $TFILE


if su -c "$OD/installPackage.sh odcontrol" admin >> $TFILE 
then
	if su -c "$OD/updateInstalledPackages.sh" admin >> $TFILE
	then
		echo "OK" >> $TFILE
	else
		echo "Cannot update!" >> $FILE
		echo "FAILED" >> $TFILE
	fi
else
	echo "Package couldn't be installed" >> $FILE
	echo "FAILED" >> $TFILE
fi
reboot
